package enterprise.manage.entity;

import javax.persistence.*;
import java.util.Calendar;
import java.util.Date;
import java.util.Set;

/**
 * Created by IntelliJ IDEA.
 * User: zhenmingyue
 * Date: 2012-11-20
 * Time: 21:38:34
 * desc：入库/出库记录
 */
@Entity
@org.hibernate.annotations.Entity(dynamicInsert = true, dynamicUpdate = true)
@Table(schema = "mg", name = "stock_info")
public class Stocks {
    /**
     * 流水号
     */
    private String stockNo;

    private Long id;
    /**
     * 入库产品ID productId
     */
    private Set<Products> inProducts;
    /**
     * 出库
     */
    private Set<Products> outProducts;

    /**
     * 创建时间
     */
    private Calendar createTime;
    /**
     * 入库/出库   采购入库、手动入库  销售出库 手动出库
     */
    private String inOrOut;
    /**
     * 订单ID orderId
     */
    private Orders order;
    /**
     * 采购单Id     purchaseId
     */
    private Purchases purchase;
    /**
     * 订单流水
     */
    private String orderNo;
    @Id
    @Column(name = "id")
    @GeneratedValue(strategy = GenerationType.AUTO)
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }
//    @ManyToOne(cascade = {CascadeType.REFRESH},fetch = FetchType.LAZY)
//    @JoinColumn(name = "productId")
//    public Products getProduct() {
//        return product;
//    }

//    public void setProduct(Products product) {
//        this.product = product;
//    }


    public Calendar getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Calendar createTime) {
        this.createTime = createTime;
    }

    public String getInOrOut() {
        return inOrOut;
    }

    public void setInOrOut(String inOrOut) {
        this.inOrOut = inOrOut;
    }

    @ManyToOne(cascade = {CascadeType.REFRESH},fetch = FetchType.LAZY)
    @JoinColumn(name = "orderId")
    public Orders getOrder() {
        return order;
    }

    public void setOrder(Orders order) {
        this.order = order;
    }
    @ManyToOne(cascade = {CascadeType.REFRESH},fetch = FetchType.LAZY)
    @JoinColumn(name = "purchaseId")
    public Purchases getPurchase() {
        return purchase;
    }

    public void setPurchase(Purchases purchase) {
        this.purchase = purchase;
    }

    public String getOrderNo() {
        return orderNo;
    }

    public void setOrderNo(String orderNo) {
        this.orderNo = orderNo;
    }

    public String getStockNo() {
        return stockNo;
    }

    public void setStockNo(String stockNo) {
        this.stockNo = stockNo;
    }
    @OneToMany(cascade = CascadeType.ALL,fetch = FetchType.LAZY,mappedBy = "inStock")
    public Set<Products> getInProducts() {
        return inProducts;
    }

    public void setInProducts(Set<Products> inProducts) {
        this.inProducts = inProducts;
    }
    @OneToMany(cascade = CascadeType.ALL,fetch = FetchType.LAZY,mappedBy = "outStock")
    public Set<Products> getOutProducts() {
        return outProducts;
    }

    public void setOutProducts(Set<Products> outProducts) {
        this.outProducts = outProducts;
    }
}
